package com.sunk.ytmall.config;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

@Configuration
@MapperScan(value={"com/sunk/ytmall/mapper"})
public class MybatisPlusConfig {

//    @Autowired
//    private SqlSessionFactory sqlSessionFactory;

    @Value("classpath:/mapper/*Mapper.xml")
    private Resource[] resources;

    /*
     * 分页插件，自动识别数据库类型
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * mybatis-plus SQL执行效率插件
     */
//    @Bean
//    public PerformanceInterceptor performanceInterceptor() {
//        return new PerformanceInterceptor();
//    }
    /*
       mybatis-plus 热部署XML
       项目启动延迟加载时间 10S
       默认刷新时间20S
     */
//    @Bean
//    public MybatisMapperRefresh mybatisMapperRefresh(){
//        return new MybatisMapperRefresh(resources,sqlSessionFactory,10,5,true);
//    }

}
